﻿using System;
public abstract class Animal
{
    public abstract void Voice();
}
public class Cat : Animal
{
    public override void Voice()
    {
        Console.WriteLine("猫：喵喵叫");
    }
}
public class Pig : Animal
{
    public override void Voice()
    {
        Console.WriteLine("猪：哼哼叫");
    }
}
public class Dog : Animal
{
    public override void Voice()
    {
        Console.WriteLine("狗：汪汪叫");
    }
}

public class Store
{
    public Animal GetInstance(string animalType)
    {
        switch (animalType.ToLower())
        {
            case "dog":
                return new Dog();
            case "pig":
                return new Pig();
            default:
                return new Cat();
        }
    }
}
class Program
{
    static void Main(string[] args)
    {
        Store petStore = new Store();
        Animal dog = petStore.GetInstance("dog");
        Animal pig = petStore.GetInstance("pig");
        Animal cat1 = petStore.GetInstance("cat");
        Animal cat2 = petStore.GetInstance("other");
        dog.Voice();
        pig.Voice();
        cat1.Voice();
        cat2.Voice();
        Console.ReadLine();
    }
}
